﻿
using Xacml.Core.Interfaces;
using Xacml.Core.Runtime;

namespace Xacml.Core.Runtime.Functions
{
  public class DoubleAdd : BaseMathOperation
  {
    public override string Id
    {
      get
      {
        return "urn:oasis:names:tc:xacml:1.0:function:double-add";
      }
    }

    public override IDataType DataType
    {
      get
      {
        return (IDataType) DataTypeDescriptor.Double;
      }
    }

    public override bool VarArgs
    {
      get
      {
        return true;
      }
    }

    public override IDataType[] Arguments
    {
      get
      {
        return new IDataType[1]
        {
          (IDataType) DataTypeDescriptor.Double
        };
      }
    }

    public override EvaluationValue Evaluate(EvaluationContext context, params IFunctionParameter[] args)
    {
      double num = 0.0;
      for (int index = 0; index < args.Length; ++index)
        num += this.GetDoubleArgument(args, index);
      return new EvaluationValue((object) num, (IDataType) DataTypeDescriptor.Double);
    }
  }
}
